<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="p" uri="/WEB-INF/tld/paging.tld"%>
<c:set var="path" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
  <head>
    <title>我的帖子</title>
    <meta name="content-type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>       
  </head>  
  <body>
    <jsp:include page="/head"></jsp:include>
	  <div class="panel panel-info" style="width: 1000px;margin-left: 200px;margin-top:52px;height: 700px">
         <div class="panel-heading"  style="height: 50px">
           <h2 class="panel-title pull-left" style="margin-top: 10px">个人中心</h2>
           <div class="pull-right">
		    <!--   <button class="btn  btn-primary" type="button" id="login_btn" onclick="update()">修改个人信息</button> -->
		      <a class="btn  btn-primary" href="<c:url value="/personal/person"/>">个人信息</a>
           </div>
         </div>
        <div class="panel-body">
             <table class="table table-responsive">
             <thead>
			      <tr>
			         <th width="100x"></th>
			         <th width="600px"></th>
			      </tr>
			   </thead>
			   <tbody>
			      <tr>
			         <td  >
					   <div style=" width:200px height:140px" >
					    <c:if test="${not empty sessionScope.user.img }">
								<img src="${sessionScope.user.img }" width="100" height="100">
								</c:if>
								<c:if test="${ empty sessionScope.user.img }">
								<img src="${path }/static/images/weishch.png" width="100" height="100"></c:if>
					   </div>
					   <h4 id="nickname" >昵称： ${user.nickname}</h4>
					</td>
			         <td id="content" colspan="1" rowspan="1">
					    <h4  style="margin-left: 20px">											   
									   <table class="table table-striped" style="font-size: 14px">
										   <thead>
											<tr>
												 <th width="400px">标题</th>
												 <th>发布时间</th>												
												 <th>回复数</th>
												 <th>操作</th>
											</tr>
										   </thead>
										   <tbody>
										    <c:forEach items="${postList }" var="plist" >
											  <tr >
												 <td><a href="${path }/reply/replies/${plist.postid }">${plist.postTitle }</a></td>
												 <td><fmt:formatDate value="${plist.postCreatetime }" pattern="yyyy-MM-dd  HH:mm:ss" /></td>												
												 <th>${plist.postResponse }</th>
												 <th><a class="btn  btn-primary" href="javascript:void(0)" onclick="del('${plist.postid}','${sessionScope.user.userid }')">删除</a> </th>
											  </tr>
											  </c:forEach>
										   </tbody>
										</table>	
										<div style="margin-left: 250px">
			<p:paging currPage="${page.pageIndex}"
			url="${path }/personal/mypost"
			totalRecords="${page.totalField }" isAppoint="false" />	</div>													 
			   </tbody>
			</table>
			
			</div>
       </div>
	 </div>
	 <!--   弹出框插件 -->
	<script type="text/javascript" charset="utf-8"
		src="${path }/static/js/teninedialog.js"></script>
 <script type="text/javascript">
 function del(postid,userid){
	$.ajax({
		url : "${path}/post/delpost",
		cache : false,
		type : "post",
		dataType : 'json',
		data : {
			postid : postid,
		
			userid : userid
		},
		success : function(da) {
			if (da=='ok') {
				$
				.teninedialog({
					title : '系统提示',
					content : '操作成功',
					showCloseButton : false,//不显示关闭按钮

					otherButtons : [ "确定" ],//其他按钮文本，样式默认,["确定","取消"]

					otherButtonStyles : [
							'btn-primary'
							 ],//其他按钮的样式，['btn-primary','btn-primary'],bootstrap按钮样式
					dialogHidden : function() {
						window.location.href ="${path}/personal/mypost";
					},
					clickButton : function(sender,
							modal, index) {
						if (index == '0') {
								 window.location.href ="${path}/personal/mypost";
								 }	
					}
			});
		}else{
			$
			.teninedialog({
				title : '系统提示',
				content : '操作失败'
				});
			
		}
		}
		
	}); 
 }
 </script>
 
  </body>
</html>
